﻿using System.Diagnostics;
using RaytracerLib.MathLib;
using YAXLib;
using System;

namespace RaytracerLib
{
    public abstract class SceneElement
    {
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        [YAXNode("Name")]
        private string m_name = "";

        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private Scene m_scene;

        public virtual string Name
        {
            get
            {
                return m_name;
            }
            set
            {
                m_name = value;
            }
        }

        public virtual Scene Scene
        {
            get
            {
                return m_scene;
            }
            internal set
            {
                if (Scene != null)
                    Scene.RenderStart -= RenderStart;
                if (Scene != null)
                    Scene.RenderEnd -= RenderEnd;

                m_scene = value;

                if (Scene != null)
                    Scene.RenderStart += RenderStart;
                if (Scene != null)
                    Scene.RenderEnd += RenderEnd;
            }
        }

        protected virtual void RenderEnd(bool a_all)
        {
        }

        protected virtual void RenderStart(RenderStartPhase a_phase)
        {
        }

        public abstract bool Remove();
    }
}